package com.zuorenke.db.extend;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Z.R.K
 * @description
 * @create 2019-04-12 15:55:42
 **/
public class Dialect {
	
	private static final Logger logger = LoggerFactory.getLogger(Dialect.class);
	
	public boolean supportsLimit() {
		return false;
	}
	
	public boolean supportsLimitOffset() {
		return supportsLimit();
	}
	
	public String getLimitString(String sql, int offset, int limit) {
		logger.error("paged queries not supported {} {} {}", sql, offset, limit);
		throw new UnsupportedOperationException("paged queries not supported");
	}
	
	public String getCountSql(String sql) {
		logger.error("not supported {}", sql);
		return null;
	}
	
	public final String getDefaultCountSql(String sql) {
		
		String mySql = getCountSql(sql);
		
		if (mySql != null && mySql.length() > 0) {
			return mySql;
		}
		return "select count(*) from (" + sql + ") leke_table";
	}
}